{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "00ab87c3",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "793e694a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Open</th>\n",
       "      <th>High</th>\n",
       "      <th>Low</th>\n",
       "      <th>Close</th>\n",
       "      <th>Volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>456.0</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-29</th>\n",
       "      <td>461.6</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-28</th>\n",
       "      <td>467.0</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-27</th>\n",
       "      <td>459.0</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-24</th>\n",
       "      <td>461.4</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "             Open   High    Low  Close    Volume\n",
       "Date                                            \n",
       "2021-09-30  456.0  464.6  453.8  461.4  17335451\n",
       "2021-09-29  461.6  465.0  450.2  465.0  18250450\n",
       "2021-09-28  467.0  476.2  464.6  469.8  20947276\n",
       "2021-09-27  459.0  473.0  455.2  464.6  17966998\n",
       "2021-09-24  461.4  473.4  456.2  460.2  16656914"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 109\n",
    "df = pd.read_csv('./00700.HK.csv', index_col=0)\n",
    "df.head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "e1752cef",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/t0/8pvkk4c568zcw6pcrv2kgqm00000gn/T/ipykernel_19080/2687987869.py:6: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  df2['c2_open'] = df2['c2_open']+10.001\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hk_open</th>\n",
       "      <th>hk_high</th>\n",
       "      <th>hk_low</th>\n",
       "      <th>hk_close</th>\n",
       "      <th>hk_volume</th>\n",
       "      <th>c2_open</th>\n",
       "      <th>c2_high</th>\n",
       "      <th>c2_low</th>\n",
       "      <th>c2_close</th>\n",
       "      <th>c2_volume</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>456.0</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "      <td>466.001</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-29</th>\n",
       "      <td>461.6</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "      <td>471.601</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-28</th>\n",
       "      <td>467.0</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "      <td>477.001</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-27</th>\n",
       "      <td>459.0</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "      <td>469.001</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-24</th>\n",
       "      <td>461.4</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "      <td>471.401</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-16</th>\n",
       "      <td>563.5</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "      <td>573.501</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-15</th>\n",
       "      <td>571.0</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "      <td>581.001</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-14</th>\n",
       "      <td>585.5</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "      <td>595.501</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-11</th>\n",
       "      <td>590.0</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "      <td>600.001</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-10</th>\n",
       "      <td>580.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "      <td>590.001</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 10 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            hk_open  hk_high  hk_low  hk_close  hk_volume  c2_open  c2_high  \\\n",
       "Date                                                                          \n",
       "2021-09-30    456.0    464.6   453.8     461.4   17335451  466.001    464.6   \n",
       "2021-09-29    461.6    465.0   450.2     465.0   18250450  471.601    465.0   \n",
       "2021-09-28    467.0    476.2   464.6     469.8   20947276  477.001    476.2   \n",
       "2021-09-27    459.0    473.0   455.2     464.6   17966998  469.001    473.0   \n",
       "2021-09-24    461.4    473.4   456.2     460.2   16656914  471.401    473.4   \n",
       "...             ...      ...     ...       ...        ...      ...      ...   \n",
       "2020-12-16    563.5    571.5   553.0     571.5   17315367  573.501    571.5   \n",
       "2020-12-15    571.0    572.0   560.0     560.0   23324922  581.001    572.0   \n",
       "2020-12-14    585.5    585.5   570.0     571.0   21177179  595.501    585.5   \n",
       "2020-12-11    590.0    590.0   582.5     588.0   12040557  600.001    590.0   \n",
       "2020-12-10    580.0    582.5   577.5     578.0   10228363  590.001    582.5   \n",
       "\n",
       "            c2_low  c2_close  c2_volume  \n",
       "Date                                     \n",
       "2021-09-30   453.8     461.4   17335451  \n",
       "2021-09-29   450.2     465.0   18250450  \n",
       "2021-09-28   464.6     469.8   20947276  \n",
       "2021-09-27   455.2     464.6   17966998  \n",
       "2021-09-24   456.2     460.2   16656914  \n",
       "...            ...       ...        ...  \n",
       "2020-12-16   553.0     571.5   17315367  \n",
       "2020-12-15   560.0     560.0   23324922  \n",
       "2020-12-14   570.0     571.0   21177179  \n",
       "2020-12-11   582.5     588.0   12040557  \n",
       "2020-12-10   577.5     578.0   10228363  \n",
       "\n",
       "[200 rows x 10 columns]"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 110\n",
    "df1 = df.head(200)\n",
    "df1.columns = ['hk_'+col.lower() for col in df.columns]\n",
    "df2 = df.head(200)\n",
    "df2.columns = ['c2_'+col.lower() for col in df.columns]\n",
    "df2['c2_open'] = df2['c2_open']+10.001\n",
    "\n",
    "df3 = pd.concat([df1, df2], axis=1)\n",
    "df3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "cd011513",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hk_open</th>\n",
       "      <th>hk_close</th>\n",
       "      <th>c2_open</th>\n",
       "      <th>c2_close</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>456.0</td>\n",
       "      <td>461.4</td>\n",
       "      <td>466.001</td>\n",
       "      <td>461.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-29</th>\n",
       "      <td>461.6</td>\n",
       "      <td>465.0</td>\n",
       "      <td>471.601</td>\n",
       "      <td>465.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-28</th>\n",
       "      <td>467.0</td>\n",
       "      <td>469.8</td>\n",
       "      <td>477.001</td>\n",
       "      <td>469.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-27</th>\n",
       "      <td>459.0</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.001</td>\n",
       "      <td>464.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-24</th>\n",
       "      <td>461.4</td>\n",
       "      <td>460.2</td>\n",
       "      <td>471.401</td>\n",
       "      <td>460.2</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "            hk_open  hk_close  c2_open  c2_close\n",
       "Date                                            \n",
       "2021-09-30    456.0     461.4  466.001     461.4\n",
       "2021-09-29    461.6     465.0  471.601     465.0\n",
       "2021-09-28    467.0     469.8  477.001     469.8\n",
       "2021-09-27    459.0     464.6  469.001     464.6\n",
       "2021-09-24    461.4     460.2  471.401     460.2"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 112\n",
    "df3[['hk_open','hk_close','c2_open','c2_close']].head(5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "a9e098d3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hk_open</th>\n",
       "      <th>hk_high</th>\n",
       "      <th>hk_low</th>\n",
       "      <th>hk_close</th>\n",
       "      <th>hk_volume</th>\n",
       "      <th>c2_open</th>\n",
       "      <th>c2_high</th>\n",
       "      <th>c2_low</th>\n",
       "      <th>c2_close</th>\n",
       "      <th>c2_volume</th>\n",
       "      <th>hk_change</th>\n",
       "      <th>c2_change</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>456.0</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "      <td>466.001</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "      <td>1.184211</td>\n",
       "      <td>-0.987337</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-29</th>\n",
       "      <td>461.6</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "      <td>471.601</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "      <td>0.736568</td>\n",
       "      <td>-1.399700</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-28</th>\n",
       "      <td>467.0</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "      <td>477.001</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "      <td>0.599572</td>\n",
       "      <td>-1.509640</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-27</th>\n",
       "      <td>459.0</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "      <td>469.001</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "      <td>1.220044</td>\n",
       "      <td>-0.938378</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-24</th>\n",
       "      <td>461.4</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "      <td>471.401</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "      <td>-0.260078</td>\n",
       "      <td>-2.376109</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-16</th>\n",
       "      <td>563.5</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "      <td>573.501</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "      <td>1.419698</td>\n",
       "      <td>-0.348910</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-15</th>\n",
       "      <td>571.0</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "      <td>581.001</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "      <td>-1.926445</td>\n",
       "      <td>-3.614624</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-14</th>\n",
       "      <td>585.5</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "      <td>595.501</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "      <td>-2.476516</td>\n",
       "      <td>-4.114351</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-11</th>\n",
       "      <td>590.0</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "      <td>600.001</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "      <td>-0.338983</td>\n",
       "      <td>-2.000163</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-10</th>\n",
       "      <td>580.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "      <td>590.001</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "      <td>-0.344828</td>\n",
       "      <td>-2.034064</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 12 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            hk_open  hk_high  hk_low  hk_close  hk_volume  c2_open  c2_high  \\\n",
       "Date                                                                          \n",
       "2021-09-30    456.0    464.6   453.8     461.4   17335451  466.001    464.6   \n",
       "2021-09-29    461.6    465.0   450.2     465.0   18250450  471.601    465.0   \n",
       "2021-09-28    467.0    476.2   464.6     469.8   20947276  477.001    476.2   \n",
       "2021-09-27    459.0    473.0   455.2     464.6   17966998  469.001    473.0   \n",
       "2021-09-24    461.4    473.4   456.2     460.2   16656914  471.401    473.4   \n",
       "...             ...      ...     ...       ...        ...      ...      ...   \n",
       "2020-12-16    563.5    571.5   553.0     571.5   17315367  573.501    571.5   \n",
       "2020-12-15    571.0    572.0   560.0     560.0   23324922  581.001    572.0   \n",
       "2020-12-14    585.5    585.5   570.0     571.0   21177179  595.501    585.5   \n",
       "2020-12-11    590.0    590.0   582.5     588.0   12040557  600.001    590.0   \n",
       "2020-12-10    580.0    582.5   577.5     578.0   10228363  590.001    582.5   \n",
       "\n",
       "            c2_low  c2_close  c2_volume  hk_change  c2_change  \n",
       "Date                                                           \n",
       "2021-09-30   453.8     461.4   17335451   1.184211  -0.987337  \n",
       "2021-09-29   450.2     465.0   18250450   0.736568  -1.399700  \n",
       "2021-09-28   464.6     469.8   20947276   0.599572  -1.509640  \n",
       "2021-09-27   455.2     464.6   17966998   1.220044  -0.938378  \n",
       "2021-09-24   456.2     460.2   16656914  -0.260078  -2.376109  \n",
       "...            ...       ...        ...        ...        ...  \n",
       "2020-12-16   553.0     571.5   17315367   1.419698  -0.348910  \n",
       "2020-12-15   560.0     560.0   23324922  -1.926445  -3.614624  \n",
       "2020-12-14   570.0     571.0   21177179  -2.476516  -4.114351  \n",
       "2020-12-11   582.5     588.0   12040557  -0.338983  -2.000163  \n",
       "2020-12-10   577.5     578.0   10228363  -0.344828  -2.034064  \n",
       "\n",
       "[200 rows x 12 columns]"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 113\n",
    "df4 = df3.copy()\n",
    "df4['hk_change'] = (df4['hk_close']/df4['hk_open']-1) *100\n",
    "df4['c2_change'] = (df4['c2_close']/df4['c2_open']-1) *100\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f6a4ae8",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>hk_open</th>\n",
       "      <th>hk_high</th>\n",
       "      <th>hk_low</th>\n",
       "      <th>hk_close</th>\n",
       "      <th>hk_volume</th>\n",
       "      <th>c2_open</th>\n",
       "      <th>c2_high</th>\n",
       "      <th>c2_low</th>\n",
       "      <th>c2_close</th>\n",
       "      <th>c2_volume</th>\n",
       "      <th>hk_change</th>\n",
       "      <th>c2_change</th>\n",
       "      <th>sim</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2021-09-30</th>\n",
       "      <td>456.0</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "      <td>466.001</td>\n",
       "      <td>464.6</td>\n",
       "      <td>453.8</td>\n",
       "      <td>461.4</td>\n",
       "      <td>17335451</td>\n",
       "      <td>1.184211</td>\n",
       "      <td>-0.987337</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-29</th>\n",
       "      <td>461.6</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "      <td>471.601</td>\n",
       "      <td>465.0</td>\n",
       "      <td>450.2</td>\n",
       "      <td>465.0</td>\n",
       "      <td>18250450</td>\n",
       "      <td>0.736568</td>\n",
       "      <td>-1.399700</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-28</th>\n",
       "      <td>467.0</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "      <td>477.001</td>\n",
       "      <td>476.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>469.8</td>\n",
       "      <td>20947276</td>\n",
       "      <td>0.599572</td>\n",
       "      <td>-1.509640</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-27</th>\n",
       "      <td>459.0</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "      <td>469.001</td>\n",
       "      <td>473.0</td>\n",
       "      <td>455.2</td>\n",
       "      <td>464.6</td>\n",
       "      <td>17966998</td>\n",
       "      <td>1.220044</td>\n",
       "      <td>-0.938378</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-09-24</th>\n",
       "      <td>461.4</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "      <td>471.401</td>\n",
       "      <td>473.4</td>\n",
       "      <td>456.2</td>\n",
       "      <td>460.2</td>\n",
       "      <td>16656914</td>\n",
       "      <td>-0.260078</td>\n",
       "      <td>-2.376109</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-16</th>\n",
       "      <td>563.5</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "      <td>573.501</td>\n",
       "      <td>571.5</td>\n",
       "      <td>553.0</td>\n",
       "      <td>571.5</td>\n",
       "      <td>17315367</td>\n",
       "      <td>1.419698</td>\n",
       "      <td>-0.348910</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-15</th>\n",
       "      <td>571.0</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "      <td>581.001</td>\n",
       "      <td>572.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>560.0</td>\n",
       "      <td>23324922</td>\n",
       "      <td>-1.926445</td>\n",
       "      <td>-3.614624</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-14</th>\n",
       "      <td>585.5</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "      <td>595.501</td>\n",
       "      <td>585.5</td>\n",
       "      <td>570.0</td>\n",
       "      <td>571.0</td>\n",
       "      <td>21177179</td>\n",
       "      <td>-2.476516</td>\n",
       "      <td>-4.114351</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-11</th>\n",
       "      <td>590.0</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "      <td>600.001</td>\n",
       "      <td>590.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>588.0</td>\n",
       "      <td>12040557</td>\n",
       "      <td>-0.338983</td>\n",
       "      <td>-2.000163</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2020-12-10</th>\n",
       "      <td>580.0</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "      <td>590.001</td>\n",
       "      <td>582.5</td>\n",
       "      <td>577.5</td>\n",
       "      <td>578.0</td>\n",
       "      <td>10228363</td>\n",
       "      <td>-0.344828</td>\n",
       "      <td>-2.034064</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>200 rows × 13 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "            hk_open  hk_high  hk_low  hk_close  hk_volume  c2_open  c2_high  \\\n",
       "Date                                                                          \n",
       "2021-09-30    456.0    464.6   453.8     461.4   17335451  466.001    464.6   \n",
       "2021-09-29    461.6    465.0   450.2     465.0   18250450  471.601    465.0   \n",
       "2021-09-28    467.0    476.2   464.6     469.8   20947276  477.001    476.2   \n",
       "2021-09-27    459.0    473.0   455.2     464.6   17966998  469.001    473.0   \n",
       "2021-09-24    461.4    473.4   456.2     460.2   16656914  471.401    473.4   \n",
       "...             ...      ...     ...       ...        ...      ...      ...   \n",
       "2020-12-16    563.5    571.5   553.0     571.5   17315367  573.501    571.5   \n",
       "2020-12-15    571.0    572.0   560.0     560.0   23324922  581.001    572.0   \n",
       "2020-12-14    585.5    585.5   570.0     571.0   21177179  595.501    585.5   \n",
       "2020-12-11    590.0    590.0   582.5     588.0   12040557  600.001    590.0   \n",
       "2020-12-10    580.0    582.5   577.5     578.0   10228363  590.001    582.5   \n",
       "\n",
       "            c2_low  c2_close  c2_volume  hk_change  c2_change  sim  \n",
       "Date                                                                \n",
       "2021-09-30   453.8     461.4   17335451   1.184211  -0.987337    0  \n",
       "2021-09-29   450.2     465.0   18250450   0.736568  -1.399700    0  \n",
       "2021-09-28   464.6     469.8   20947276   0.599572  -1.509640    0  \n",
       "2021-09-27   455.2     464.6   17966998   1.220044  -0.938378    0  \n",
       "2021-09-24   456.2     460.2   16656914  -0.260078  -2.376109    1  \n",
       "...            ...       ...        ...        ...        ...  ...  \n",
       "2020-12-16   553.0     571.5   17315367   1.419698  -0.348910    0  \n",
       "2020-12-15   560.0     560.0   23324922  -1.926445  -3.614624    1  \n",
       "2020-12-14   570.0     571.0   21177179  -2.476516  -4.114351    1  \n",
       "2020-12-11   582.5     588.0   12040557  -0.338983  -2.000163    1  \n",
       "2020-12-10   577.5     578.0   10228363  -0.344828  -2.034064    1  \n",
       "\n",
       "[200 rows x 13 columns]"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 114\n",
    "df4['sim'] = (df4['hk_change']*df4['c2_change'] > 0)*1\n",
    "df4"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "990735e9",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "72.5"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 115\n",
    "res = df4['sim'].sum() / len(df4)\n",
    "res*100"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "base",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
